package com.newbie.iSee;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

import com.facebook.android.Facebook;

public class ShareTools {
	public static Facebook facebook;
	public static Facebook_interface facebookInterface;
	public static WebInterface webInterface;
	public static LocalDatabase localDatabase;
	
	public static void initialize(Context context) {
		localDatabase = new LocalDatabase(context);
		localDatabase.load();
	}
	
	public static String uid;
	public static String uname;
	public static String[] Friends;
    public static boolean isConnectInternet(Context context) {
    	ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    	NetworkInfo ni = cm.getActiveNetworkInfo();
    	if(ni != null && ni.isConnected() && ni.isAvailable())
    		return true;
    	return false;
    }
    
    public static boolean isLogin() {
    	if(facebook == null)
    		return false;
    	
    	return facebook.isSessionValid();
    }
    public static String[] getNames(Comment[] comments){
 	
    	if(comments==null)return null;
    	String[] names = new String[comments.length];
    	int i;
    	for(i = 0; i<comments.length; i++){
    		names[i] = comments[i].from;
    	}
    	return names;
    	
    	
    	
    }
    public static String[] getContents(Comment[] comments){
    	
    	
    	if(comments==null)return null;
    	String[] contents = new String[comments.length];
    	int i;
    	for(i = 0; i<comments.length; i++){
    		contents[i] = comments[i].message;
    	}
    	return contents;
    	
    }
    public static String[] parsed_friends_list(Friend[] friends){
		if(friends ==null) return null;
		int i;
		String[] fid_list = new String[friends.length];
		for(i=0; i<friends.length; i++){
			fid_list[i] = friends[i].uid;
			 Log.d("uid","fid:"+fid_list[i]);
			
		}
		return fid_list;
		
    }
}
